<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>删除相邻字符串</title>
</head>

<body>
  <script>
    function delSrt(str) {
      let res = [], nowStr
      for (let i = 0; i < str.length; i++) {
        if (str.charAt(i) != nowStr) {
          res.push(str.charAt(i));
          nowStr = str.charAt(i);
        }
      }
      return res.join("")
    }
    console.log(delSrt("aabcc1b1fhh"));
  </script>
</body>

</html>